<html>
<head><meta charset="utf-8"><title>implementing the expect RFC · t-compiler/wg-incr-comp · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/241847-t-compiler/wg-incr-comp/index.html">t-compiler/wg-incr-comp</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/241847-t-compiler/wg-incr-comp/topic/implementing.20the.20expect.20RFC.html">implementing the expect RFC</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="239766649"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/241847-t-compiler/wg-incr-comp/topic/implementing%20the%20expect%20RFC/near/239766649" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/241847-t-compiler/wg-incr-comp/topic/implementing.20the.20expect.20RFC.html#239766649">(May 21 2021 at 15:13)</a>:</h4>
<p>Hey <span class="user-mention" data-user-id="124287">@mw</span> -- I'm thinking about how to implement <a href="https://github.com/rust-lang/rust/issues/85549">https://github.com/rust-lang/rust/issues/85549</a> (cc <span class="user-mention" data-user-id="369415">@xFrednet</span>).</p>



<a name="239766668"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/241847-t-compiler/wg-incr-comp/topic/implementing%20the%20expect%20RFC/near/239766668" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/241847-t-compiler/wg-incr-comp/topic/implementing.20the.20expect.20RFC.html#239766668">(May 21 2021 at 15:13)</a>:</h4>
<p>It doesn't fit especially well with our incremental system.</p>



<a name="239766689"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/241847-t-compiler/wg-incr-comp/topic/implementing%20the%20expect%20RFC/near/239766689" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/241847-t-compiler/wg-incr-comp/topic/implementing.20the.20expect.20RFC.html#239766689">(May 21 2021 at 15:14)</a>:</h4>
<p>What we need to do is to be able to tell:</p>
<ul>
<li>were any lints generated within this node?</li>
</ul>



<a name="239766758"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/241847-t-compiler/wg-incr-comp/topic/implementing%20the%20expect%20RFC/near/239766758" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/241847-t-compiler/wg-incr-comp/topic/implementing.20the.20expect.20RFC.html#239766758">(May 21 2021 at 15:14)</a>:</h4>
<p>of course, those lints could be generated at any point in compilation</p>



<a name="239766834"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/241847-t-compiler/wg-incr-comp/topic/implementing%20the%20expect%20RFC/near/239766834" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/241847-t-compiler/wg-incr-comp/topic/implementing.20the.20expect.20RFC.html#239766834">(May 21 2021 at 15:15)</a>:</h4>
<p>I think this is a case where I would really want a model more like the adapton model</p>



<a name="239766854"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/241847-t-compiler/wg-incr-comp/topic/implementing%20the%20expect%20RFC/near/239766854" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/241847-t-compiler/wg-incr-comp/topic/implementing.20the.20expect.20RFC.html#239766854">(May 21 2021 at 15:15)</a>:</h4>
<p>where you can "push writes" to a bit of "mutable state"</p>



<a name="239766863"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/241847-t-compiler/wg-incr-comp/topic/implementing%20the%20expect%20RFC/near/239766863" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/241847-t-compiler/wg-incr-comp/topic/implementing.20the.20expect.20RFC.html#239766863">(May 21 2021 at 15:15)</a>:</h4>
<p>(a collection of "seen lints")</p>



<a name="239766939"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/241847-t-compiler/wg-incr-comp/topic/implementing%20the%20expect%20RFC/near/239766939" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/241847-t-compiler/wg-incr-comp/topic/implementing.20the.20expect.20RFC.html#239766939">(May 21 2021 at 15:15)</a>:</h4>
<p>I've thought about how to model that within salsa</p>



<a name="239766953"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/241847-t-compiler/wg-incr-comp/topic/implementing%20the%20expect%20RFC/near/239766953" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/241847-t-compiler/wg-incr-comp/topic/implementing.20the.20expect.20RFC.html#239766953">(May 21 2021 at 15:15)</a>:</h4>
<p>I was going to setup a method that generates "side effects"</p>



<a name="239766964"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/241847-t-compiler/wg-incr-comp/topic/implementing%20the%20expect%20RFC/near/239766964" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/241847-t-compiler/wg-incr-comp/topic/implementing.20the.20expect.20RFC.html#239766964">(May 21 2021 at 15:15)</a>:</h4>
<p>which basically get collected in a side-vector along the main result</p>



<a name="239766985"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/241847-t-compiler/wg-incr-comp/topic/implementing%20the%20expect%20RFC/near/239766985" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/241847-t-compiler/wg-incr-comp/topic/implementing.20the.20expect.20RFC.html#239766985">(May 21 2021 at 15:15)</a>:</h4>
<p>and accumulated by the (transitive) set of queries that a query Q performs</p>



<a name="239766998"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/241847-t-compiler/wg-incr-comp/topic/implementing%20the%20expect%20RFC/near/239766998" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/241847-t-compiler/wg-incr-comp/topic/implementing.20the.20expect.20RFC.html#239766998">(May 21 2021 at 15:15)</a>:</h4>
<p>so that you can say "what side effects were part of Q"</p>



<a name="239767015"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/241847-t-compiler/wg-incr-comp/topic/implementing%20the%20expect%20RFC/near/239767015" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/241847-t-compiler/wg-incr-comp/topic/implementing.20the.20expect.20RFC.html#239767015">(May 21 2021 at 15:15)</a>:</h4>
<p>and you get all the side-effects from Q and any queries that it transitively executed</p>



<a name="239767076"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/241847-t-compiler/wg-incr-comp/topic/implementing%20the%20expect%20RFC/near/239767076" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/241847-t-compiler/wg-incr-comp/topic/implementing.20the.20expect.20RFC.html#239767076">(May 21 2021 at 15:16)</a>:</h4>
<p>that way the lint pass could ask "what expect lints were seen" (for example)</p>



<a name="239767104"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/241847-t-compiler/wg-incr-comp/topic/implementing%20the%20expect%20RFC/near/239767104" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/241847-t-compiler/wg-incr-comp/topic/implementing.20the.20expect.20RFC.html#239767104">(May 21 2021 at 15:16)</a>:</h4>
<p>I've yet to come up with a better idea, maybe that's just the thing to do ?</p>



<a name="239767256"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/241847-t-compiler/wg-incr-comp/topic/implementing%20the%20expect%20RFC/near/239767256" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/241847-t-compiler/wg-incr-comp/topic/implementing.20the.20expect.20RFC.html#239767256">(May 21 2021 at 15:17)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116009">nikomatsakis</span> <a href="#narrow/stream/241847-t-compiler.2Fwg-incr-comp/topic/implementing.20the.20expect.20RFC/near/239766834">said</a>:</p>
<blockquote>
<p>I think this is a case where I would really want a model more like the adapton model</p>
</blockquote>
<p>What is the adapton model?</p>



<a name="239767440"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/241847-t-compiler/wg-incr-comp/topic/implementing%20the%20expect%20RFC/near/239767440" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/241847-t-compiler/wg-incr-comp/topic/implementing.20the.20expect.20RFC.html#239767440">(May 21 2021 at 15:18)</a>:</h4>
<p><a href="http://adapton.org/">http://adapton.org/</a></p>



<a name="239767453"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/241847-t-compiler/wg-incr-comp/topic/implementing%20the%20expect%20RFC/near/239767453" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/241847-t-compiler/wg-incr-comp/topic/implementing.20the.20expect.20RFC.html#239767453">(May 21 2021 at 15:18)</a>:</h4>
<p>I dont' actually think we want that</p>



<a name="239767471"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/241847-t-compiler/wg-incr-comp/topic/implementing%20the%20expect%20RFC/near/239767471" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/241847-t-compiler/wg-incr-comp/topic/implementing.20the.20expect.20RFC.html#239767471">(May 21 2021 at 15:18)</a>:</h4>
<p>I like the query system, it can be explained relatively easily</p>



<a name="239767479"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/241847-t-compiler/wg-incr-comp/topic/implementing%20the%20expect%20RFC/near/239767479" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/241847-t-compiler/wg-incr-comp/topic/implementing.20the.20expect.20RFC.html#239767479">(May 21 2021 at 15:18)</a>:</h4>
<p>the side-effects that I describe are a nice fit</p>



<a name="240174877"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/241847-t-compiler/wg-incr-comp/topic/implementing%20the%20expect%20RFC/near/240174877" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mw <a href="https://rust-lang.github.io/zulip_archive/stream/241847-t-compiler/wg-incr-comp/topic/implementing.20the.20expect.20RFC.html#240174877">(May 25 2021 at 11:47)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> I'll let you know when I had time to think about this is some detail</p>



<a name="240214894"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/241847-t-compiler/wg-incr-comp/topic/implementing%20the%20expect%20RFC/near/240214894" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/241847-t-compiler/wg-incr-comp/topic/implementing.20the.20expect.20RFC.html#240214894">(May 25 2021 at 16:33)</a>:</h4>
<p>I might prototype my proposal in salsa, <span class="user-mention" data-user-id="124287">@mw</span></p>



<a name="240235174"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/241847-t-compiler/wg-incr-comp/topic/implementing%20the%20expect%20RFC/near/240235174" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cjgillot <a href="https://rust-lang.github.io/zulip_archive/stream/241847-t-compiler/wg-incr-comp/topic/implementing.20the.20expect.20RFC.html#240235174">(May 25 2021 at 19:07)</a>:</h4>
<p>Diagnostics are already saved and replayed by the incr. comp. engine. Adding a <code>source_lint: (HirId, Lint)</code> to the <code>Diagnostic</code> struct may provide with the necessary information. Then, an iteration over all the emitted diagnostics would have the necessary information to mark the <code>expect</code> attribute as used.</p>



<a name="240235871"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/241847-t-compiler/wg-incr-comp/topic/implementing%20the%20expect%20RFC/near/240235871" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cjgillot <a href="https://rust-lang.github.io/zulip_archive/stream/241847-t-compiler/wg-incr-comp/topic/implementing.20the.20expect.20RFC.html#240235871">(May 25 2021 at 19:13)</a>:</h4>
<p>Another possibility would be to create some kind of <code>mark_attribute</code> query, and verify at the end of a compilation whether a DepNode for <code>mark_attribute(my_attr)</code> exists. The query engine will attempt to mark this query green, so it will create a DepNode in the current session with it. At the end of the compilation session, we just need to check the query's cache for filled/empty buckets.</p>



<a name="240243599"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/241847-t-compiler/wg-incr-comp/topic/implementing%20the%20expect%20RFC/near/240243599" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> xFrednet <a href="https://rust-lang.github.io/zulip_archive/stream/241847-t-compiler/wg-incr-comp/topic/implementing.20the.20expect.20RFC.html#240243599">(May 25 2021 at 20:11)</a>:</h4>
<p><span class="user-mention silent" data-user-id="248906">cjgillot</span> <a href="#narrow/stream/241847-t-compiler.2Fwg-incr-comp/topic/implementing.20the.20expect.20RFC/near/240235174">said</a>:</p>
<blockquote>
<p>Diagnostics are already saved and replayed by the incr. comp. engine. Adding a <code>source_lint: (HirId, Lint)</code> to the <code>Diagnostic</code> struct may provide with the necessary information. Then, an iteration over all the emitted diagnostics would have the necessary information to mark the <code>expect</code> attribute as used.</p>
</blockquote>
<p>Interesting, after reading this comment I've found a query called <a href="https://doc.rust-lang.org/nightly/nightly-rustc/rustc_query_impl/plumbing/struct.QueryCtxt.html#method.store_diagnostics"><code>store_diagnostics</code></a> with a corresponding <a href="https://doc.rust-lang.org/nightly/nightly-rustc/rustc_query_impl/plumbing/struct.QueryCtxt.html#method.load_diagnostics"><code>load_diagnostics</code></a> query. I'll investigate that lead for a bit <span aria-label="upside down" class="emoji emoji-1f643" role="img" title="upside down">:upside_down:</span></p>



<a name="240300126"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/241847-t-compiler/wg-incr-comp/topic/implementing%20the%20expect%20RFC/near/240300126" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mw <a href="https://rust-lang.github.io/zulip_archive/stream/241847-t-compiler/wg-incr-comp/topic/implementing.20the.20expect.20RFC.html#240300126">(May 26 2021 at 09:48)</a>:</h4>
<p>Yes, we do record diagnostics for each query and store them so they can be replayed in a subsequent compilation session without actually re-executing the query. This is safe because there is no way to access the value of the diagnostics from a query, so no query result can depend on these "side effects". Extending that to also record data about lints being produced seems fine as long as we guarantee that that data is only accessed after the last query has been executed, right? </p>
<p>We could think about an adapton-like extension to the query system where we have "queries" that can be written to and that panic if a write occurs after their result has been read for the first time. As long as the writes a query are completely determined by its inputs that should work too. However, I'd like to keep the query system as simple as possible, so unless this is really necessary I'd rather not go that route.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>